"""This module is a wrapper for rules requests"""

from pypalo.basic import response, url, default, arguments

request_group="rule"

def create(definition, activate, external_identifier, comment, use_identifier, cube, database, sid, host=default["host"], port=default["port"]):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/rule/create[?PARAMETER1=value[&...]].
	
	Parameters:
		database [identifier] <Identifier of a database>
		cube [identifier] <Identifier of a cube>
		definition [string] <Urlencoded enterprise rule>
		activate [integer] <create active rule with "1" (default) or a not active rule with "0">
		external_identifier [string] <Urlencoded external identifier>
		comment [string] <Urlencoded comment>
		use_identifier [boolean] <Use identifier in textual representation of the rule in the result. The definition can use name or identifier independent of the parameter.>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>

	Result:
		0 rule [identifier] <Identifier of the rule>
		1 rule_string [string] <Textual representation for the rule>
		2 external_identifier [string] <external identifier of the rule>
		3 comment [string] <comment for the rule>
		4 timestamp [string] <creation time of the rule in seconds since 1970-01-01>
		5 active [integer] <0=rule is not active, 1=rule is active>
	
	More info at http://host:port/api/rules/create
	'''
	#beginning of function suite
	request_name="create"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def destroy(rule, cube, database, sid, host=default["host"], port=default["port"]):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/rule/destroy[?PARAMETER1=value[&...]].
	
	Parameters:
		database [identifier] <Identifier of a database>
		cube [identifier] <Identifier of a cube>
		rule [identifier] <Identifier of the rule>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>

	Result:
		0 OK [boolean] <"1" means OK>
	
	More info at http://host:port/api/rules/destroy
	'''
	#beginning of function suite
	request_name="destroy"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def functions(sid, host=default["host"], port=default["port"]):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/rule/functions[?PARAMETER1=value[&...]].
	
	Parameters:
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>

	Result:
		0 xml_functions [string] <XML representation of the functions.>
	
	More info at http://host:port/api/rules/functions
	'''
	#beginning of function suite
	request_name="functions"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def info(use_identifier, rule, cube, database, sid, host=default["host"], port=default["port"]):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/rule/info[?PARAMETER1=value[&...]].
	
	Parameters:
		database [identifier] <Identifier of a database>
		cube [identifier] <Identifier of a cube>
		rule [identifier] <Identifier of rule to show>
		use_identifier [boolean] <Use identifier in textual representation of the rule in the result. The definition can use name or identifier independent of the parameter.>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>

	Result:
		0 rule [identifier] <Identifier of the rule>
		1 rule_string [string] <Textual representation for the rule>
		2 external_identifier [string] <external identifier of the rule>
		3 comment [string] <comment for the rule>
		4 timestamp [string] <creation time of the rule in seconds since 1970-01-01>
		5 active [integer] <0=rule is not active, 1=rule is active>
	
	More info at http://host:port/api/rules/info
	'''
	#beginning of function suite
	request_name="info"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def modify(definition, activate, external_identifier, comment, use_identifier, rule, cube, database, sid, host=default["host"], port=default["port"]):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/rule/modify[?PARAMETER1=value[&...]].
	
	Parameters:
		database [identifier] <Identifier of a database>
		cube [identifier] <Identifier of a cube>
		rule [identifier] <Identifier of rule to modify>
		definition [string] <Urlencoded enterprise rule>
		activate [integer] <create active rule with "1" (default) or a not active rule with "0">
		external_identifier [string] <Urlencoded external identifier>
		comment [string] <Urlencoded comment>
		use_identifier [boolean] <Use identifier in textual representation of the rule in the result. The definition can use name or identifier independent of the parameter.>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>

	Result:
		0 rule [identifier] <Identifier of the rule>
		1 rule_string [string] <Textual representation for the rule>
		2 external_identifier [string] <external identifier of the rule>
		3 comment [string] <comment for the rule>
		4 timestamp [string] <creation time of the rule in seconds since 1970-01-01>
		5 active [integer] <0=rule is not active, 1=rule is active>
	
	More info at http://host:port/api/rules/modify
	'''
	#beginning of function suite
	request_name="modify"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def parse(definition, sid, host=default["host"], port=default["port"], **keywords):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/rule/parse[?PARAMETER1=value[&...]].
	
	Parameters:
		database [identifier] <Identifier of a database>
		cube [identifier] <Identifier of a cube>
		functions [string] <List of function names>
		definition [string] <Urlencoded enterprise rule>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>

	Result:
		0 xml_rule [string] <XML representation of the enterprise rule.>
	
	More info at http://host:port/api/rules/parse
	'''
	#beginning of function suite
	request_name="parse"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

#querys dictionary
query={}
query["create"]=create
query["destroy"]=destroy
query["functions"]=functions
query["info"]=info
query["modify"]=modify
query["parse"]=parse

#end of rules module suite